home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-10-13 | 3.5 KB | 110 lines | [TEXT/CWIE] |
- /* TestBanks.c */
- //
- // Bo3b: This is the main routine for testing to see if the Ram banks
- // are interleaved or not. It tests the situation by using the Hammerhead
- // magic registers.
- //
- // Hence the magic numbers of bankN and interleaveMask.
- //
- // It maps out the data into the input array, which is used as the raw data
- // to print out the DIMM setup. This part just returns what is in the
- // HammerHead registers, because the mapping to DIMM slot is machine
- // dependent.
-
- /* Bit 2 on = Interleave for both SIMMs */
- /* => 9500 | 75&8500 */
- /* 1C0: Bank 0/1 - Motherboard => Motherboard */
- /* 200: Bank 2/3 - DIMM 0/1 Front => A1/B1 | B4/A4 */
- /* 240: Bank 4/5 - DIMM 0/1 Back => A1/B1 | B4/A4 */
- /* 280: Bank 6/7 - DIMM 2/3 Front => A2/B2 | B3/A3 */
- /* 2C0: Bank 8/9 - DIMM 2/3 Back => A2/B2 | B3/A3 */
- /* 300: Bank 10/11- DIMM 4/5 Front => A3/B3 | B2/A2 */
- /* 340: Bank 12/13- DIMM 4/5 Back => A3/B3 | B2/A2 */
- /* 380: Bank 14/15- DIMM 6/7 Front => A4/B4 | B1/A1 */
- /* 3C0: Bank 16/17- DIMM 6/7 Back => A4/B4 | B1/A1 */
- /* 400: Bank 18/19- DIMM 8/9 Front => A5/B5 */
- /* 440: Bank 20/21- DIMM 8/9 Back => A5/B5 */
- /* 480: Bank 22/23- DIMM 10/11 Front=> A6/B6 */
- /* 4C0: Bank 24/25- DIMM 10/11 Back => A6/B6 */
-
-
- #include <types.h>
- #include <gestalt.h>
- #include <errors.h>
-
- #include "Interleave.h"
-
-
- #define interleaveMask 0x04
- #define adrs1Mask 0x01
- #define adrs1Shift 8
- #define MegPerAdrs 4
-
-
- // Formerly:
- //void TestBanks (short *InterleaveBank, short *RAMbank);
-
-
- //==============================================================
- // Get the ram bank info by playing with the HammerHead registers.
- // Sets up the RAMBankDescriptors.
-
- OSErr
- GetPhysicalRAMBankInfo(RAMBankDescriptorPtr theBanks, UInt32 fullMemSize, Ptr hammerHeadBase)
- {
- Ptr bankN;
- short i;
-
- // We are on the proper hardware, go ahead and fiddle with the naughty bits.
-
- bankN = hammerHeadBase + 0x1C0;
-
- for (i=0; i<=25; i++)
- {
- theBanks[i].bankIsInterleaved = *bankN & interleaveMask;
- theBanks[i].bankSize = (*bankN) & adrs1Mask ;
- bankN = bankN + 0x10;
- theBanks[i].bankSize = (theBanks[i].bankSize << adrs1Shift) + (*bankN);
- bankN = bankN + 0x10;
- }
-
- // Now theBanks.bankSize fields are set up with the address (upper bits)
- // of the starting location of each bank. This doesn't match the interface,
- // where we want to give each bank's individual size. Go
- // through and calculate the size of each bank by determining deltas.
- // And multiply by 4, so that they become actual Meg counts.
- // If the bank is interleaved, copy half the meg count up to the next
- // bank. And, mark the second as interleaved too. This normalizes the
- // banks, from the data received by fiddling with bits.
-
- for (i = 0; i < 25; i++)
- {
- theBanks[i].bankSize = (theBanks[i+1].bankSize - theBanks[i].bankSize) * MegPerAdrs;
- }
-
- // For the very last element, we need the full memory size, and subtract
- // the starting address at theBanks[25] in order to figure it's delta size.
- // We need to divide fullMemSize by 4, since the other params are 4 Meg chunks.
-
- theBanks[25].bankSize = (fullMemSize / 4 - theBanks[25].bankSize) * MegPerAdrs;
-
- // If a bank is interleaved, copy half the meg count up to the next
- // bank. This normalizes the banks, from the data received by
- // fiddling with bits.
-
- for (i = 0; i < 25; i++)
- {
- if (theBanks[i].bankIsInterleaved) {
- theBanks[i+1].bankSize = theBanks[i].bankSize / 2;
- theBanks[i].bankSize = theBanks[i+1].bankSize;
- }
- }
-
- return (noErr);
- }
-
-
-
-
-
-